//
//  MPTLiveKongZhiTaiView.m
//  MPTLive
//
//  Created by HouGeng on 16/3/18.
//  Copyright © 2016年 Jeakin. All rights reserved.
//

#import "MPTLiveKongZhiTaiView.h"

@interface MPTLiveKongZhiTaiView()
{
    TPButton *butShan;
    
    TPButton *butJing;
    
    TPButton *butMei;
    
    TPButton *butYu;
    
    TPButton *butJie;
}

@end

@implementation MPTLiveKongZhiTaiView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews
{
    [self show];
    
    CGFloat fltKong = (screenW - 52 * 5) / 6;
    CGFloat fltTop = 20;
    CGFloat fltW = 52;
    /// 闪光灯
    butShan = [TPButton getWithFrame:CGRectMake(fltKong, fltTop, fltW, 65)];
    [butShan setImage:[UIImage imageNamed:@"sanguangdengN"] forState:UIControlStateNormal];
    [butShan setImage:[UIImage imageNamed:@"sanguangdengS"] forState:UIControlStateSelected];
    [self addSubview:butShan];
    
    /// 镜头
    butJing = [TPButton getWithFrame:CGRectMake(CGRectGetMaxX(butShan.frame) + fltKong, fltTop, fltW, 65)];
    [butJing setImage:[UIImage imageNamed:@"JIngTouN"] forState:UIControlStateNormal];
    [self addSubview:butJing];
    
    /// 美艳
    butMei = [TPButton getWithFrame:CGRectMake(CGRectGetMaxX(butJing.frame) +fltKong, fltTop, fltW, 65)];
    [butMei setImage:[UIImage imageNamed:@"meiyanN"] forState:UIControlStateNormal];
    [butMei setImage:[UIImage imageNamed:@"meiyanS"] forState:UIControlStateSelected];
    [self addSubview:butMei];
    
    /// 语音
    butYu = [TPButton getWithFrame:CGRectMake(CGRectGetMaxX(butMei.frame) +fltKong, fltTop, fltW, 65)];
    [butYu setImage:[UIImage imageNamed:@"huatongN"] forState:UIControlStateNormal];
    [butYu setImage:[UIImage imageNamed:@"huatongS"] forState:UIControlStateSelected];
    [self addSubview:butYu];
    
    /// 结束
    butJie = [TPButton getWithFrame:CGRectMake(CGRectGetMaxX(butYu.frame) + fltKong, fltTop, fltW, 65)];
    [butJie setImage:[UIImage imageNamed:@"jieShuN"] forState:UIControlStateNormal];
    [butJie setImage:[UIImage imageNamed:@"jieShuS"] forState:UIControlStateHighlighted];
    [self addSubview:butJie];
    
    /// 关闭的手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(butGuan)];
    [self addGestureRecognizer:tap];
    
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(butGuan)];
    swipe.direction = UISwipeGestureRecognizerDirectionUp;
    [self addGestureRecognizer:swipe];
}

/// 关闭直播的方法
- (void)setTargetForBtn:(id)target  withGuanbi:(SEL)action
{
    [butJie addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

/// 镜头
- (void)setTargetForBtn:(id)target  withJingt:(SEL)action
{
    [butJing addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

/// 灯
- (void)setTargetForBtn:(id)target  withSanGuanDeng:(SEL)action
{
    [butShan addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

/// 静音
- (void)setTargetForBtn:(id)target  withJIngYin:(SEL)action
{
    [butYu addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

/// 滤镜
- (void)setTargetForBtn:(id)target  withLvJing:(SEL)action
{
    [butMei addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
}

- (void)show
{
    [UIView animateWithDuration:0.3 animations:^{
        self.frame = CGRectMake(0, 0, screenW, self.frame.size.height);
    }];
    
}

- (void)butGuan
{
    [UIView animateWithDuration:0.25 animations:^{
        self.frame = CGRectMake(0, -self.frame.size.height, screenH, self.frame.size.height);
    } completion:^(BOOL finished) {
        
    }];
}

@end
